package com.example.travel.utils;

import java.util.UUID;

public class PubDef {

    /**
     * 生成订单编号
     */
    public static String generateOrderCode() {// 生成标准UUID（36位，含连字符）
        UUID uuid = UUID.randomUUID();
        return uuid.toString();
    }

    /**
     *  将 ISO 8601 格式转换为 yyyy-MM-dd HH:mm:ss
     */
    public static String formatTime(String time){
        String formattedDate = "";
        try{
            java.time.Instant instant = java.time.Instant.parse(time);
            java.time.LocalDateTime localDateTime = java.time.LocalDateTime.ofInstant(instant, java.time.ZoneId.systemDefault());
            formattedDate = localDateTime.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            System.out.println("ERROR:"+e);
        }
        return formattedDate;
    }

}
